package com.example.cloud.controller;

import com.example.cloud.service.ConsumerServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @date 2024/5/6
 */
@RestController
@RequestMapping("/consumer")
public class NacosConsumerController {

    @Autowired
    private ConsumerServiceImpl consumerService;

    @Autowired
    private RestTemplate restTemplate;
    public static final String GOODS_SERVICE_PROVIDER_PREFIX = "http://goods-service/";

    @GetMapping("/getName")
    public String getName() {
        // 调用goods-service服务接口
        return restTemplate.getForObject(GOODS_SERVICE_PROVIDER_PREFIX + "provider/getName", String.class);
    }
}
